<?php

namespace App\Http\Controllers\Long;

use App\Http\Controllers\Controller;
use App\Models\AccountsInfo;
use Illuminate\Support\Facades\DB;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Support\Facades\Request;

class AccountsController extends BaseController
{
    /**
     * 用户管理
     */
    public function index(AccountsInfo $AccountsInfo){
        $this->getSearchParams();
        $conditions = array();
        if(isset($this->searchParams['userID']) && $this->searchParams['userID']){
            $conditions[] = ['userID' ,'like' , $this->searchParams['userID'].'%'];
        }
        if(isset($this->searchParams['gameID']) && $this->searchParams['gameID']){
            $conditions[] = ['gameID' ,'like' , $this->searchParams['gameID'].'%'];
        }
        $accounts = $AccountsInfo->where($conditions)->offset($this->getPageOffset())->limit(config('constant.pageSize'))->orderBy('UserID', 'desc')->get()->toArray();
        $total = $AccountsInfo->where($conditions)->count();
        return view('accounts.index' , array(
            'account'=>json_encode($accounts),
            'total' => $total,
            'currentPageShow' => $this->getCurrentPage(),
            'searchParams' => $this->searchParams
        ));
    }
}
